<?php
function check($username) {
    $username = trim($username);
    if (empty($username)) {
        return "Feld ist leer.";
    }elseif (strlen($username) < 4) {
        return "hat weniger als 4 Zeichen";
    }elseif (strlen($username) > 26) {
        return "hat mehr als 26 Zeichen";
    }elseif (!preg_match('~^[a-z]{2}~i', $username)) {
        return "username must start with two letters";
    }elseif (preg_match('~[^a-z0-9_.]+~i', $username)) {
        return "username contains invalid characters.";
    }elseif (substr_count($username, ".") > 1) {
        return "username may only contain one or less periods.";
    }elseif (substr_count($username, "_") > 1) {
        return "username may only contain one or less underscores.";
    }

    return true;
} 
?>